package com.example.businescalender_maps;
//import com.example.businescalender.*;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import android.content.ComponentName;
import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import java.lang.Object;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class Businesscalender_maps extends MapActivity {
    /** Called when the activity is first created. */
	MapView mapview;
	MapController mapcontroller;
	GeoPoint geopoint;
	LocationManager locmanager;
	LocationListener loclistener;
    @SuppressWarnings("unchecked")
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mapview=(MapView) findViewById(R.id.mapView);
        mapcontroller=mapview.getController();
        Locale locale=new Locale("hi_IN");
        Geocoder geocoder=new Geocoder(this,locale);
        String place="darmasagar,warangal,india";
        try
        {
        	
        	final Intent intent = new Intent(Intent.ACTION_MAIN, null);

        	intent.addCategory(Intent.CATEGORY_LAUNCHER);

        	final ComponentName cn = new ComponentName("com.example.businessCalender", "com.example.businessCalender.AddEvent");

        	intent.setComponent(cn);

        	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        	startActivity( intent);

        	/*Intent intent = new Intent(Intent.ACTION_RUN);
        	intent.setComponent(new ComponentName("com.example.businessCalender", "AddEvent.class"));
        	Object packageManager;
			List list = packageManager.queryIntentActivities(intent, packageManager.COMPONENT_ENABLED_STATE_DEFAULT);

        	if(list.size() > 0)
        	{
        	 Log.i("Log", "Have application" + list.size());
        	 startActivity(intent);
        	}
        	else
        	{
        	    Log.i("Log", "None application");
        	}
*/
        	
        	List<Address> addresses=geocoder.getFromLocationName(place, 18);
        	if(addresses.size()>0)
        	{
        		geopoint=new GeoPoint((int)(addresses.get(0).getLatitude()*1E6), (int)(addresses.get(0).getLongitude()*1E6));
        		mapcontroller.animateTo(geopoint);
        		mapview.setSatellite(true);
        		mapcontroller.setZoom(18);
        		mapview.invalidate();
        	}
        }
        	catch(IOException e)
        	{
        		e.printStackTrace();
        	}
        }

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return true;
	}
}